package com.ruoyi.common.core.domain.entity;
import com.ruoyi.common.core.domain.BaseEntity;

import java.util.Arrays;

public class LineData extends BaseEntity {

    private String[] lineDataDate;
    private Double[] lineDataTotal;


    public String[] getLineDataDate() {
        return lineDataDate;
    }

    public void setLineDataDate(String[] lineDataTotal) {
        this.lineDataDate = lineDataDate;
    }

    public Double[] getLineDataTotal() {
        return lineDataTotal;
    }

    public void setLineDataTotal(Double[] lineDataTotal) {
        this.lineDataTotal = lineDataTotal;
    }

    // 添加数据到数组中
    public void addData(String date, Double total) {
        if (lineDataDate == null || lineDataTotal == null) {
            // 如果数组为空，创建新数组
            lineDataDate = new String[1];
            lineDataTotal = new Double[1];
        } else {
            // 如果数组不为空，创建新数组并复制原数组内容
            int newSize = lineDataDate.length + 1;
            String[] newDateArray = Arrays.copyOf(lineDataDate, newSize);
            Double[] newTotalArray = Arrays.copyOf(lineDataTotal, newSize);
            lineDataDate = newDateArray;
            lineDataTotal = newTotalArray;
        }

        // 将新数据添加到数组末尾
        lineDataDate[lineDataDate.length - 1] = date;
        lineDataTotal[lineDataTotal.length - 1] = total;
    }

}
